Skip to content

fix(core): honor escaped hashes and whitespace in ignore patterns - #1544

Merged
phernandez merged 2 commits into
mainfrom
codex/finish-1540
Sep 14, 2026
Merged

phernandez merged 2 commits into
mainfrom
codex/finish-1540

Conversation

@phernandez

Copy link
Copy Markdown
Member

Why

Escaped hash patterns such as \#*# must ignore Emacs autosave files. This finishes @wangzhengzhuo05's contribution in #1540 for #1539 and addresses the Codex P2: \#foo must match #foo, without excluding #foo.

Fixes #1539. Replacement for #1540.

What Changed

Both .bmignore and project .gitignore load escaped hashes while preserving significant leading whitespace. Unescaped trailing spaces are discarded; escaped spaces remain literal.

Implementation Details

Preserves @wangzhengzhuo05's original commit fbffd1a11798cc947fd47d447b4c55899980f6ec, rebased as 6d47871a6a8625c53da5705e6f8a2fffe5a03a16, with its author and DCO signoff intact. git range-diff confirms the contributor patch is unchanged. The maintainer correction is a separate signed-off commit on top of current main (ffbb6e9d66b6db73aafa370f5a5386bff3cb9186).

The shared line parser removes line endings, skips comments at column zero, and decodes escaped hashes, spaces, and backslashes together before passing patterns to the existing fnmatch matcher. This preserves escape pairing and avoids stripping leading whitespace. No dependency or default ignore patterns changed.

Testing

  • uv run pytest tests/cli/test_ignore_utils.py -q: 39 passed, including 22 new cases across both loaders for leading whitespace, \#foo, trailing tabs, CRLF, and escaped/unescaped trailing spaces.
  • Independent git check-ignore --no-index comparison: all 22 positive/negative filename expectations agree with Git.
  • just fast-check: passed (ruff lint, format, and full just typecheck). The fresh environment initially lacked optional pymilvus; installed the declared pymilvus>=3.0.0,<4 dependency and reran successfully.
  • just doctor: passed, including file creation, indexing, search, and status in an isolated temporary project.
  • git diff --check: passed.

Risks / Follow-ups

This remains the existing fnmatch-based subset of gitignore syntax; it does not introduce full gitignore matching or negation support. CI and exact-head Codex review must complete before merge. This PR is intentionally left unmerged.

wangzhengzhuo05 and others added 2 commits September 13, 2026 22:26
.bmignore documents gitignore-style syntax, but the loader skipped any line
beginning with '#' and never unescaped a leading backslash, so no pattern
beginning with a hash could take effect: '#*#' was dropped as a comment and
'\#*#' was stored literally and never matched. Strip one leading backslash when
a line starts with '\#', for both .bmignore and project .gitignore, so e.g.
'\#*#' loads as '#*#' (Emacs autosave files).

Fixes #1539

Signed-off-by: wangzhengzhuo05 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-14T03:43:13.628490Z ee2f854 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ee2f8545bc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/basic_memory/ignore_utils.py
@phernandez

Copy link
Copy Markdown
Member Author

@codex review — Please reassess head ee2f854 after the evidence-based scope response in the resolved ZIP-import thread. That importer and its matcher are unchanged from main; this PR finishes the contributor filesystem-loader fix and its significant-whitespace regression.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: ee2f8545bc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@phernandez
phernandez merged commit d4c080f into main Sep 14, 2026
38 checks passed
@phernandez
phernandez deleted the codex/finish-1540 branch September 14, 2026 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] .bmignore cannot express any pattern beginning with #, despite documenting gitignore-style syntax

2 participants